from django.db import models
from users.models import Ops_user


# Create your models here.

class System_variable(models.Model):
    '''
    系统环境变量
    '''
    var_lable = models.CharField(max_length=128, verbose_name='变量描述')
    var_name = models.CharField(max_length=128, unique=True, blank=False, verbose_name='变量Key')
    var_value = models.CharField(max_length=128, verbose_name='变量Value')
    edit_user = models.ForeignKey(to=Ops_user, on_delete=models.DO_NOTHING, blank=True, verbose_name='修改人',
                                  db_constraint=False)
    var_group = models.SmallIntegerField(verbose_name='数字分组', default=0)
    edit_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')

    def edit_user_name(self):
        return self.edit_user.username

    class Meta:
        db_table = 'ops_system_variable'
        verbose_name = '主机表'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.var_name
